package fiveagon.lsystem;

abstract class AbstractGrammar {
  private String sentence;

  AbstractGrammar(String axiom) {
    this.sentence = axiom;
  }

  public final void generate() {
    generate(1);
  }

  public final void generate(int numGenerations) {
    for (int i = 0; i < numGenerations; i++) {
      sentence = generate(sentence);
    }
  }

  @Override
  public final String toString() {
    return sentence;
  }

  abstract String generate(String s);
}
